package com.aji.service.impl;

import com.aji.dto.Ores3AddDto;
import com.aji.dto.Ores3ChangeDto;
import com.aji.entity.Ores1;
import com.aji.entity.Ores1Select;
import com.aji.entity.Ores2;
import com.aji.entity.Ores3;
import com.aji.mapper.LocMapper;
import com.aji.service.LocService;
import com.aji.vo.Ores3Vo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LocServiceImpl implements LocService {
    @Autowired
    LocMapper locMapper;
    @Override
    public List<Ores1> selectOres1() {
        return locMapper.selectOres1();
    }

    @Override
    public List<Ores2> selectOres2ByOres1(Integer ores1Id) {
        return locMapper.selectOres2ByOres1(ores1Id);
    }

    @Override
    public List<Ores3> selectOres3ByOres2(Integer ores1Id,Integer ores2Id) {
        return locMapper.selectOres3ByOres2(ores1Id,ores2Id);
    }

    @Override
    public void upDateOres1ById(Integer ores1Id, String ores1Name) {
        locMapper.upDateOres1ById(ores1Id,ores1Name);
    }

    @Override
    public void upDateOres2ById(Integer ores2Id, String ores2Name) {
        locMapper.upDateOres2ById(ores2Id,ores2Name);
    }

    @Override
    public void upDateOres3ById(Integer ores3Id, Ores3ChangeDto ores3ChangeDto) {
        Ores3 ores3 = Ores3.builder().ores3Name(ores3ChangeDto.getOres3Name())
                .ores3Id(ores3Id).latitude(ores3ChangeDto.getLatitude())
                .longtitude(ores3ChangeDto.getLongtitude()).build();
        locMapper.upDateOres3ById(ores3);
    }

    @Override
    public void addOres1(String ores1Name) {
        locMapper.addOres1(ores1Name);
    }

    @Override
    public void addOres2(String ores2Name, Integer ores1Id) {
        locMapper.addOres2(ores2Name,ores1Id);
    }

    @Override
    public void addOres3(Ores3AddDto ores3AddDto, Integer ores2Id) {
        Ores3 ores3 = Ores3.builder().ores3Name(ores3AddDto.getOres3Name())
                .latitude(ores3AddDto.getLatitude()).ores2Id(ores2Id)
                .longtitude(ores3AddDto.getLongtitude()).build();
        locMapper.addOres3(ores3);
    }

    @Override
    public void deleteByIds1(List<Integer> ids) {
        locMapper.deleteByIds1(ids);
    }

    @Override
    public void deleteByIds2(List<Integer> ores2Ids) {
        locMapper.deleteByIds2(ores2Ids);
    }

    @Override
    public void deleteByIds3(List<Integer> ores3Ids) {
        locMapper.deleteByIds3(ores3Ids);
    }

    @Override
    public Ores3Vo selectOres3ById(Integer ores3Id) {
        return locMapper.selectOres3ById(ores3Id);
    }

    @Override
    public List<Ores1Select> selectAll() {
        return locMapper.selectAll();
    }

    @Override
    public Integer selectOres3IdByCon(Ores3AddDto ores3AddDto) {
        return locMapper.selectOres3IdByCon(ores3AddDto);
    }

    @Override
    public List<Ores2> selectOres2() {
        return locMapper.selectOres2();
    }

    @Override
    public List<Ores3> selectOres3() {
        return locMapper.selectOres3();
    }
}
